#ifndef __CCMS_NR_MEM_STATS_H__
#define __CCMS_NR_MEM_STATS_H__

/**
 * @file ccms/nr/mem_stats.h
 *
 * MemStats class header file.
 */

#include "ccms/nr/types.h"

namespace ccms {
namespace nr {

/**
 * MemUsageS structure, holds information about memory usage of particular types.
 *
 * All values stored in this structure are in kilobytes.
 */
typedef struct MemUsageS {
    unsigned long physTotal;   /**< total amount of physical memory */
    unsigned long physFree;    /**< amount of free physical memory */
    unsigned long physBuffers; /**< amount of physical memory used as system buffers */
    unsigned long physCached;  /**< amount of physical memory used as system cache */
    unsigned long physUsed;    /**< amount of physical memory used by processes running within the system */
    unsigned long swapTotal;   /**< total amount of swap memory */
    unsigned long swapFree;    /**< amount of free swap memory */
    unsigned long swapUsed;    /**< amount of used swap memory */
} MemUsage;

/**
 * MemStats class, holds the information about system-wide memory usage.
 */
class MemStats
{
    public:

        /**
         * Default constructor.
         */
        MemStats(void);

        /**
         * Updates the internal data from /proc.
         */
        void update(void);

        /**
         * Returns the memory usage of a particular mode obtained
         * by the most recent update call.
         *
         * @param mode - memory usage mode (type)
         * @throw InvalidParameterException if an invalid mode is passed
         * @return memory usage of the particular memory usage mode (type)
         */
        unsigned long getMemUsage(const MemUsageMode mode) const;

    private:

        /**
         * Memory usage values from the most recent update call.
         */
        MemUsage memUsage;
};

} // namespace nr
} // namespace ccms

#endif /* __CCMS_NR_MEM_STATS_H__ */
